
#ifndef _STRING_SPLITTER_
#define _STRING_SPLITTER_
#include "Common/Definitions.h"

#include <vector>

namespace ttg
{
	namespace strings
	{
		//Splits given string according to setted splitters.
		class StringSplitter
		{
			private:
				bool isSplitter[256];
				bool isVisible[256];
				char *raw;
				std::vector<const char *> lexems;
			public:
				//Creates empty StringSpliiter.
				//Note: setSplitter() and setString() must be called before using other methods.
				StringSplitter();
				//Sets given character as splitter.
				//If "isVisible" is true, this char will be considered as lexem.
				//Otherwise it will be ignored.
				void setSplitter(char key, bool isVisible);
				//Sets string for splitting.
				void setString(const char *value);
				//Returns count of the lexems.
				inline size_t getCount()
						{ return lexems.size(); }
				//Returns n-th lexem without boundary checking.
				inline const char *getSubString(size_t n)
						{ return lexems[n]; }
				//Returns n-th lexem without boundary checking.
				inline const char *operator [](const size_t n)
						{ return this->getSubString(n); }
				//Creates one string from lexems.
				std::string join(const char *separator);
				//Releases StringSplitter and all assosiated resources.
				~StringSplitter();
		};
	}
}

#endif
